﻿<Window  x:Class="BandAid.Window1" Loaded="Window_Loaded"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:custom="clr-namespace:BandAid"
    Title="BandAid" Width="800" Height="600" AllowsTransparency="False" WindowStyle="SingleBorderWindow" Icon="/BandAid;component/Resources/appIcon.png">
    <Window.Resources>
        <ObjectDataProvider x:Key="songs" ObjectType="{x:Type custom:Archives}" MethodName="GetSongArchive"/>
        <ObjectDataProvider x:Key="artists" ObjectType="{x:Type custom:Archives}" MethodName="GetArtistArchive"/>
        <ObjectDataProvider x:Key="places" ObjectType="{x:Type custom:Archives}" MethodName="GetPlaceArchive"/>
        <ObjectDataProvider x:Key="shows" ObjectType="{x:Type custom:Archives}" MethodName="GetShowArchive" />
        <ObjectDataProvider x:Key="showSongs" ObjectType="{x:Type custom:Archives}" MethodName="GetShowSongArchive"/>
        
        <DataTemplate x:Key="songsTemplate" DataType="BandAid.SongArchive">
            <Grid Margin="10" LostFocus="Grid_LostFocus">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition Width="40" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Label Grid.Row="0" Grid.Column="0">Artist</Label>
                <ComboBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Source={StaticResource artists}}" DisplayMemberPath="NAME" SelectedValuePath="ID" SelectedValue="{Binding Path=ARTIST_ID}" />
                
                <Label Grid.Row="0" Grid.Column="1">Title</Label>
                <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=TITLE}" />
                
                <Label Grid.Row="0" Grid.Column="2">Length</Label>
                <TextBox  Grid.Row="1" Grid.Column="2" Text="{Binding Path=LENGTH}" />
                
                <Label Grid.Row="0" Grid.Column="3">Video</Label>
                
                <Button Grid.Column="4" Click="AddToCurrentShow">+</Button>
            </Grid>
        </DataTemplate>
       
        
        <DataTemplate x:Key="artistsTemplate" DataType="BandAid.ArtistArchive">
            <Grid Margin="10" LostFocus="Grid_LostFocus">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition Width="250" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
              
                    <Label Grid.Column="0" Grid.Row="0">Name</Label>
                    <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=NAME}" />
              
        
                    <Label Grid.Column="0" Grid.Row="1">Default rights owner</Label>
                    <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=DEFAULT_SIAE_OWNER}" />
             

            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="showSongsTemplate" DataType="BandAid.ShowSongArchive">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>


                <TextBox Grid.Column="0"  Text="No." />
                <TextBox Grid.Column="1"  Text="{Binding Path=SONG.SongArtist}" />
                <TextBox Grid.Column="2"  Text="{Binding Path=SONG.TITLE}" />
                <Button Grid.Column="3" Click="DeleteSongFromShow">X</Button>


            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition ></ColumnDefinition>
            <ColumnDefinition Width="350"></ColumnDefinition>
        </Grid.ColumnDefinitions>
    <ScrollViewer Grid.Column="0">
        <StackPanel >     
        
                <Expander Header="Artists">
            <GroupBox>
                <StackPanel>
                    <ListBox Name="ArtistsList" ItemsSource= "{Binding Source={StaticResource artists}}" ItemTemplate="{StaticResource artistsTemplate}">
                    </ListBox>

                    <WrapPanel>
                        <Button Width="20" Content="-" Click="Delete_Artist"/>
                        <Button Width="20" Content="+" Click="New_Artist"/>
                    </WrapPanel>
                </StackPanel>
            </GroupBox>
        </Expander>
        
       
                <Expander Header="Places">
                    <ListBox Name="PlaceList" ItemsSource="{Binding Source={StaticResource places}}" />
                </Expander>
                <Expander Header="Songs">
                    <GroupBox>
                        <StackPanel>
                            <ListBox Name="SongList" ItemsSource= "{Binding Source={StaticResource songs}}" ItemTemplate="{StaticResource songsTemplate}" >
                            </ListBox>
                            <WrapPanel>
                                <Button  Width="20" Content="-" Click="Delete_Song"/>
                                <Button Width="20" Content="+" Click="New_Song"/>
                            </WrapPanel>
                        </StackPanel>
                    </GroupBox>
                </Expander>
            
                <Expander Header="Shows">
                    <ListBox Name="ShowList" ItemsSource="{Binding Source={StaticResource shows}}" IsSynchronizedWithCurrentItem="True" />
                </Expander>
                    
               
     
            </StackPanel>
   </ScrollViewer>
        
        <StackPanel Grid.Column="1">
            <ListBox Name="ShowSongsList" ItemTemplate="{StaticResource showSongsTemplate}" ItemsSource="{Binding Source={StaticResource showSongs}}"></ListBox>
            
        </StackPanel>
    </Grid>
</Window>
